/*
    Android UIML

	Copyright (C) 2010  Bram Goffings (bramgoffings@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package uiml.android.elements;

import org.w3c.dom.Element;

public class Structure extends UimlElementWithAttributes{
	
	// TODO comment
	private Part top = null;
	
	// TODO comment
	public static String IAM = "structure";
	
	/**
	 * 
	 * @param node
	 */
	public Structure(Element node) {
		super(node);
		System.out.println("Structure element aangemaakt");
		process();
	}

	/**
	 * 
	 */
	@Override
	public void processElement(Element elem) {
		if(elem.getTagName().equals(Part.IAM)) {
			if(top == null) {
				if(getNumberChildElements() > 1) // we don't have a root yet and more than one part ==> surround parts with container
					top = new Part("top-container", "Frame");
				else // no root and a single part
					top = new Part(elem);
			}
			else // we have a root, add parts to this root
				top.addChild(new Part(elem));
		}
	}

	/**
	 * 
	 * @param m_top
	 */
	public void setTop(Part m_top) {
		this.top = m_top;
	}

	/**
	 * 
	 * @return
	 */
	public Part getTop() {
		return top;
	}

}
